#pragma once

#include <entt/entt.hpp>
#include <unordered_map>

#include "components.hpp"

#include "qlib/all.h"

#include "event.hpp"

#include "../../ecs/event.hpp"

#include "../../ecs/query.hpp"

namespace qbe::shear {

struct Param {
  Param(qbe::ecs::EventWriter<Event> _eventWriter) : eventWriter(_eventWriter) {}

  bool have_copy_obj() { enable; }
  void reset() { enable = false; }

  void clear(entt::registry& reg) {
    auto view = reg.view<ShearTag>();

    view.each([&reg](entt::entity e) { reg.remove<ShearTag>(e); });

    eventWriter.send({Code::End});
  }

  bool enable = false;

  qbe::ecs::EventWriter<Event> eventWriter;

  static entt::registry* reg;
  static qlib::Cell::s_ptr cell;
  static ecs::Query* query;
};

}  // namespace qbe::shear